-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: refactor labels #1145
base: main
Are you sure you want to change the base?
fix: refactor labels #1145
Conversation
|
✅ Deploy Preview for harness-design ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for harness-xd-review ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
apps/gitness/src/pages-v2/pull-request/pull-request-compare.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure I follow why this file/hook exists in the first place.
cc @cjlee01 @sans-harness can we discuss once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hook was created to populate data in the store (useLabelsStore
). It's used on the labels list page and on the repository label details page. Essentially, it's just isolated code moved into a hook to fill the store, avoiding repetitive code.
apps/gitness/src/pages-v2/project/labels/hooks/use-get-project-label-and-values-data.ts
Outdated
Show resolved
Hide resolved
apps/gitness/src/pages-v2/project/labels/project-labels-list-container.tsx
Outdated
Show resolved
Hide resolved
apps/gitness/src/pages-v2/project/labels/project-labels-list-container.tsx
Outdated
Show resolved
Hide resolved
apps/gitness/src/pages-v2/repo/labels/hooks/use-full-fill-label-store.ts
Outdated
Show resolved
Hide resolved
width={width || size} | ||
height={height || size} | ||
className={className} | ||
style={{ minWidth: `${width || size}px`, minHeight: `${height || size}px` }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious why this was needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Icon component is often used in layouts in a way that unintentionally reduces its width (e.g., due to flex), which is incorrect behavior. This code ensures that the icon maintains its width in any layout.
> | ||
{!!value && <span className="max-w-full truncate">{value}</span>} | ||
|
||
{!!counter && counter} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this means that counting from 0
is not allowed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes you are right, 0 not allowed
)} | ||
</span> | ||
|
||
{isDynamic && <Icon name="circle-plus" size={12} className="min-w-3 text-icons-4" />} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have any meaning that as screen reader should be made aware of?
)} | ||
|
||
{hasShortcut && !!shortcutLetter && ( | ||
<div className="absolute right-1.5 top-1/2 flex h-5 -translate-y-1/2 cursor-pointer items-center gap-0.5 rounded-sm border bg-background-3 px-1 text-foreground-2 duration-100 ease-in-out"> | ||
<Icon name="apple-shortcut" size={12} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to annoy everyone who's not on a Mac.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@knagurski that's a fair point :) But I think it'd be better to move this to a separate task, if you don't mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, totally, just an observation when we were in the area
packages/ui/src/views/labels/components/label-form-color-and-name-group.tsx
Outdated
Show resolved
Hide resolved
packages/ui/src/views/labels/components/label-form-color-and-name-group.tsx
Show resolved
Hide resolved
504ac7e
to
b9f6a26
Compare
if (!branchError) return | ||
|
||
if (pullReqMetadata?.merged || pullReqMetadata?.closed) { | ||
return setShowRestoreBranchButton(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best to only return cleanup functions from a useEffect
. This will be fine, but it's probably best to separate the call and the return since they aren't really connected.
return setShowRestoreBranchButton(true) | |
setShowRestoreBranchButton(true) | |
return |
@@ -13,14 +13,16 @@ export interface UseFullFillLabelStoreProps { | |||
export const useFullFillLabelStore = ({ queryPage, query, enabled = true }: UseFullFillLabelStoreProps) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question about the naming... is it "full fill" as in two words, or "fulfil" as in to complete something? Maybe it would be more obvious what the purpose of the hook was as something like usePopulateLabelsStore
or usePrimeLabelsStore
?
import { cn } from '@utils/cn' | ||
import { ColorsEnum } from '@views/labels' | ||
import { ColorsEnum, ILabelType, LabelType } from '@views/labels' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we find a way to avoid references to the views
from within components
? Ideally this should be one-way to make it clear that views bring components together into a cohesive interface, leaving components as independent building blocks. Perhaps should LabelMarker
be a subcomponent of the Labels view?
<span | ||
className={`flex h-full items-center overflow-hidden rounded-r bg-label-background-black pl-1.5 pr-[7px] ${inTable && 'max-w-[50%]'}`} | ||
<div className={cn('flex max-w-full items-center gap-2 opa relative', className)}> | ||
<span |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This being a span
(an inline element), but being set as display grid (a block level element) doesn't really make much sense to me. Is there a reason we can't use a div
? Makes no difference, but I'm curious if there's a reason as I've seen inline elements being changed to block a lot in this codebase 🤔
const isWithExtraContent = !!value || !!counter | ||
const isWithDeleteButton = !!onDelete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can totally ignore this since it makes zero difference... instead of isWith
, has
reads better IMO
const isWithExtraContent = !!value || !!counter | |
const isWithDeleteButton = !!onDelete | |
const hasExtraContent = !!value || !!counter | |
const hasDeleteButton = !!onDelete |
@@ -43,7 +43,7 @@ TableHeader.displayName = 'TableHeader' | |||
|
|||
const TableBody = forwardRef<HTMLTableSectionElement, HTMLAttributes<HTMLTableSectionElement>>( | |||
({ className, ...props }, ref) => ( | |||
<tbody ref={ref} className={cn('[&_tr:last-child]:border-0', className)} {...props} /> | |||
<tbody ref={ref} className={cn('[&_tr:last-child]:border-0 [&>tr:hover]:bg-background-4', className)} {...props} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me a change of colour on hover denotes that something is clickable. This might be the ideal for the usage in the labels work, but I don't think we can make that call for all tables. Can we make this opt-in as, perhaps, an extra prop?
return label.assigned_value?.id ?? undefined | ||
} | ||
|
||
return undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to manually return undefined
; if you don't return anything, you'll get the same
return undefined |
Adjusted multiple components to the design
Added missing functionalities:
Fixed the Icon component size: in flex containers, it could shrink
Design changes (before/after):